using System;

namespace ELS.Configuration
{
	#region ConfigurationObjectBase
	/// <summary>
	///  Acts as a base class for deriving items in a configuration.
	/// </summary>
	public abstract class ConfigurationObjectBase
	{
		private ConfigurationObjectBase _parent = null;
		/// <summary>
		/// Gets the name of the current given <see cref="ELS.Configuration.ConfigurationObjectBase "/>.
		/// </summary>
		public abstract string Name	{ get; }

		/// <summary>
		/// Gets the immediate parent object of the current given <see cref="ELS.Configuration.ConfigurationObjectBase "/>.
		/// </summary>
		public ConfigurationObjectBase Parent 
		{ 
			get { return _parent;  }
			set { _parent = value; } 
		}

		/// <summary>
		/// Gets the fully qualified name of the current given <see cref="ELS.Configuration.ConfigurationObjectBase "/>.
		/// </summary>
		public string FullName
		{
			get 
			{
				string fullName = this.Name;
				ConfigurationObjectBase cfgObject = this._parent;
				while ( cfgObject != null )
				{
					fullName = cfgObject.Name + "." + fullName;
					cfgObject = cfgObject.Parent;
				}
				return fullName;
			}
		}
	}
	#endregion ConfigurationObjectBase
}
